package com.itheima.code.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.Map;


public class HandlerContext1 {

    private Map<String,Class> handlerMap;


    public HandlerContext1(Map<String, Class> handlerMap) {
        this.handlerMap = handlerMap;
    }

    public  AbstractHandler getInstance(String type){
        Class aClass = handlerMap.get(type);
        if (aClass == null){
            System.out.println("没有获取对象");
        }
        return (AbstractHandler) SpringContextUtil.getBean(aClass);
    }
}
